import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

export const querySchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'planName',
    label: '方案名称',
  },
  {
    component: 'RadioGroup',
    componentProps: {
      buttonStyle: 'solid',
      optionType: 'button',
    },
    fieldName: 'status',
    label: '启用状态',
  },
  {
    component: 'Input',
    fieldName: 'projectId',
    label: '所属项目id',
  },
  {
    component: 'Input',
    fieldName: 'trialId',
    label: '所属实验id',
  },
];

// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
// export const columns: () => VxeGridProps['columns'] = () => [
export const columns: VxeGridProps['columns'] = [
  { type: 'checkbox', width: 60 },
  {
    title: '方案名称',
    field: 'planName',
  },

  {
    title: '所属项目',
    field: 'projectName',
  },
  {
    title: '所属实验',
    field: 'trialName',
  },
  {
    title: '创建时间',
    field: 'createTime',
  },
  {
    title: '创建人',
    field: 'createByName',
  },
  {
    title: '启用状态',
    field: 'status',
    slots: { default: 'status' },
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    width: 180,
  },
];

export const drawerSchema: FormSchemaGetter = () => [
  {
    fieldName: 'id',
    component: 'Input',
    dependencies: {
      show: () => false,
      triggerFields: [''],
    },
  },
  {
    label: '方案名称',
    fieldName: 'planName',
    component: 'Input',
    rules: 'required',
  },
  {
    label: '所属项目',
    fieldName: 'projectId',
    component: 'ApiSelect',
    rules: 'required',
  },
  {
    label: '所属实验',
    fieldName: 'trialId',
    component: 'Select',
    rules: 'required',
  },
  {
    label: '所属分组',
    fieldName: 'trialGroupId',
    component: 'Select',
    rules: 'required',
  },
  {
    label: '启用状态',
    fieldName: 'status',
    component: 'RadioGroup',
    defaultValue: '0',
    rules: 'required',
    componentProps: {
      buttonStyle: 'solid',
      optionType: 'button',
      options: [
        {
          label: '已启用',
          value: '0',
        },
        {
          label: '未启用',
          value: '1',
        },
      ],
    },
  },
];
